package com.summer.random;

import java.util.Random;

public class RedEnvelope {
	
	private int participationNumber = 100;
	private int amount = 10000;
	private float bigPrize = 0.7f;
	private int groupSize = 10;
	
	public static void main(String[] args) {
	
		
		
	}
	
	public int[] group(){
		int[] group = new int[groupSize];
		float scope = bigPrize;
		for(int index=0;index < groupSize-1;index++){
			float rand = randFloat(0,(int)(scope*100));
			scope = (1 - rand)*bigPrize;
			group[index] = (int)(amount * rand);
		}
		group[groupSize-1] = (int)(amount * scope);
		return group;
	}
	
	
	
	public static int randInt(int min, int max) {
	    Random rand = new Random();
	    int randomNum = rand.nextInt((max - min) + 1) + min;
	    return randomNum;
	}
	
	public static float randFloat(int min, int max) {
		int rand = randInt(min,max);
		return rand/100f;
	}
	
}
